package org.jianfa.mq.seckill.controller;

import org.jianfa.mq.seckill.entity.vo.GoodsVo;
import org.jianfa.mq.seckill.entity.vo.Result;
import org.jianfa.mq.seckill.mapper.SeckillGoodsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SeckillGoodsListController {

    @Autowired
    private SeckillGoodsMapper seckillGoodsMapper;

    @GetMapping("/seckill/seckillGoodsList")
    public Result<List<GoodsVo>> seckillGoodsList() {
        List<GoodsVo> goodsVos = seckillGoodsMapper.selectWithDetailAll();
        return Result.success(goodsVos);
    }

    @GetMapping("/seckill/seckillGood")
    public Result<GoodsVo> seckillGoodsList(@RequestParam("id") long id) {
        GoodsVo goodsVo = seckillGoodsMapper.selectWithDetailByPrimaryKey(id);
        return Result.success(goodsVo);
    }
}
